<?php

/**
 * PracticaPlan form base class.
 *
 * @method PracticaPlan getObject() Returns the current form's model object
 *
 * @package    COLEGIO_FONOAUDIOLOGIA
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BasePracticaPlanForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                 => new sfWidgetFormInputHidden(),
      'practica_id'        => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Practica'), 'add_empty' => false)),
      'plan_id'            => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Plan'), 'add_empty' => false)),
      'codigo_obra_social' => new sfWidgetFormInputText(),
      'valor_obra_social'  => new sfWidgetFormInputText(),
      'coseguro'           => new sfWidgetFormInputText(),
      'created_at'         => new sfWidgetFormDateTime(),
      'updated_at'         => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'                 => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'practica_id'        => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Practica'))),
      'plan_id'            => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Plan'))),
      'codigo_obra_social' => new sfValidatorString(array('max_length' => 20)),
      'valor_obra_social'  => new sfValidatorNumber(array('required' => false)),
      'coseguro'           => new sfValidatorInteger(array('required' => false)),
      'created_at'         => new sfValidatorDateTime(),
      'updated_at'         => new sfValidatorDateTime(),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorDoctrineUnique(array('model' => 'PracticaPlan', 'column' => array('codigo_obra_social')))
    );

    $this->widgetSchema->setNameFormat('practica_plan[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'PracticaPlan';
  }

}
